package flc.ast.adapter;

import android.graphics.Color;
import android.view.View;

import androidx.annotation.NonNull;

import com.chad.library.adapter.base.provider.BaseItemProvider;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;

import flc.ast.R;
import flc.ast.bean.MyCameraTypeBean;
import stark.common.basic.adaptermutil.StkProviderMultiAdapter;
import stark.common.basic.adaptermutil.StkSingleSpanProvider;

public class CameraTypeAdapter extends StkProviderMultiAdapter<MyCameraTypeBean> {

    public CameraTypeAdapter() {
        addItemProvider(new StkSingleSpanProvider<>(90));
        addItemProvider(new CameraTypeProvider());
    }

    private class CameraTypeProvider extends BaseItemProvider<MyCameraTypeBean> {
        @Override
        public int getItemViewType() {
            return StkProviderMultiAdapter.TYPE_VIEW;
        }

        @Override
        public int getLayoutId() {
            return R.layout.item_camera_type;
        }

        @Override
        public void convert(@NonNull BaseViewHolder baseViewHolder, MyCameraTypeBean bean) {
            if (bean.isSelected()) {
                baseViewHolder.getView(R.id.rlCameraTypeItemSel).setVisibility(View.VISIBLE);
                baseViewHolder.getView(R.id.rlCameraTypeItem).setVisibility(View.GONE);
                baseViewHolder.setImageResource(R.id.ivCameraTypeItemImgSel, bean.getImgSel());
            } else {
                baseViewHolder.getView(R.id.rlCameraTypeItemSel).setVisibility(View.GONE);
                baseViewHolder.getView(R.id.rlCameraTypeItem).setVisibility(View.VISIBLE);
                baseViewHolder.setImageResource(R.id.ivCameraTypeItemImg, bean.getImgSel());
            }
        }
    }
}
